#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<string.h>
#include<fcntl.h>
#include<sys/wait.h>

int main()
{
  int pipefd[2]={0};
  int res = pipe(pipefd);
  if(res<0)
  {
    perror("pipe error");
    return -1;
  }
  int ret=fork();
  if(ret==0)
  {
    char* data ="今天是大年初一\n";
    write(pipefd[1],data,strlen(data));
    //execlp("ls","ls","-l",NULL);
    exit(0);
  }

  ret=fork();
  if(ret==0)
  {
    char buf[1024]={0};
    read(pipefd[0],buf,1023);
    printf("%s\n",buf);
    exit(0);
  }

  wait(NULL);
  wait(NULL);

  return 0;
}
